package operation;

import abbot.finder.ComponentNotFoundException;
import abbot.finder.MultipleComponentsFoundException;
import abbot.finder.matchers.ClassMatcher;
import abbot.tester.JListTester;

import javax.swing.*;
import java.awt.*;

/**
 * Created by caolp on 2017-03-14.
 */
public class ListOperation extends Operation {

    public ListOperation(JList jList){
        container = jList;
    }
    public ListOperation() throws ComponentNotFoundException, MultipleComponentsFoundException {
        container = (Container) searchComponent(new ClassMatcher(JList.class));
    }
    /**
     *点击JList中指定item项,是通过getText方法做的比对。
     * @param itemName item名称
     */
    public void selectItem(String itemName) {
        new JListTester().actionSelectItem(container,itemName);
    }

    public void selectIndex(int index) {
        new JListTester().actionSelectIndex(container,index);
    }

}
